<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <style>

  *{
   margin:0;
   padding:0
  }

  </style>
</head>

<body>
  <input type="text"> <button>发送验证码</button>

</body>

  <script>
    var button = document.querySelector('button');
    button.onclick = function(){
      var time = 5;
      button.innerText =time+'s';
      button.disabled=true;
     var tr = setInterval(function(){
        time--;
        button.innerText =time+'s';
        if(time ==0){
          button.disabled=false;
          button.innerText ='发送验证码';
          clearInterval(tr);
        }
      },1000)
    }
  </script>
</html>
